
///自定义类，身份证信息实体
class IdCardInfo{
  String? name;
  String? sex;
  String? folk;//民族信息
  String? birt;//1986年10月10日
  String? addr;
  String? num;//身份证号码
  String? issue;
  String? valid;

  //识别后保存头像文件路径
  String? headPath;
  //识别后保存图片文件路径
  String? imgPath;

  //将图片路径放到 头像照路径中
  String? portraitUrl;
  //将图片路径放到  国徽照路径中
  String? backUrl;

  IdCardInfo(
      {this.name,
      this.sex,
      this.folk,
      this.birt,
      this.addr,
      this.num,
      this.issue,
      this.valid,
      this.headPath,
      this.imgPath,
      this.portraitUrl,
      this.backUrl});

  IdCardInfo.fromJson(dynamic json){
    if(json == null)return;
    this.name = json['name'];
    this.sex = json['sex'];
    this.folk = json['folk'];
    this.birt = json['birt'];
    this.addr = json['addr'];
    this.num = json['num'];
    this.issue = json['issue'];
    this.valid = json['valid'];
    this.headPath = json['headPath'];
    this.imgPath = json['imgPath'];
    this.portraitUrl = json['portraitUrl'];
    this.backUrl = json['backUrl'];
  }

  Map<String,dynamic> toJson(){
    Map<String,dynamic> map = {};
    map['name'] = this.name;
    map['sex'] = this.sex;
    map['folk'] = this.folk;
    map['birt'] = this.birt;
    map['addr'] = this.addr;
    map['num'] = this.num;
    map['issue'] = this.issue;
    map['valid'] = this.valid;
    map['imgPath'] = this.imgPath;
    map['headPath'] = this.headPath;
    map['portraitUrl'] = this.portraitUrl;
    map['backUrl'] = this.backUrl;
    return map;
  }

  ///根据是否是身份证头像信息，更新信息
  update(bool isPortrait, IdCardInfo info){
    //图片统一保存在imgPath
    if(isPortrait){
      this.name = info.name;
      this.sex = info.sex;
      this.folk = info.folk;
      this.birt = info.birt;
      this.addr = info.addr;
      this.num = info.num;
      this.imgPath = info.imgPath;
      this.headPath = info.headPath;
      this.portraitUrl = info.imgPath;
    }else{
      this.issue = info.issue;
      this.valid = info.valid;
      this.imgPath = info.imgPath;
      this.backUrl = info.imgPath;
    }
  }

}